#ifndef __UART_H
#define __UART_H

/*************************************



**************************************/
#include "um_conf.h"
#include "mcu.h"
#include "umtype.h"



void __attribute__ ((weak)) USART1_RxParse(u16 rdata);
void __attribute__ ((weak)) USART2_RxParse(u16 rdata);
void __attribute__ ((weak)) USART3_RxParse(u16 rdata);
#ifdef UM_MCU_HAS_UART4
void __attribute__ ((weak)) UART4_RxParse(u16 rdata);
#endif
#ifdef UM_MCU_HAS_UART5
void __attribute__ ((weak)) UART5_RxParse(u16 rdata);
#endif


typedef enum
{
	NOT_NEED_MAP = 0,
	NEED_MAP = !NOT_NEED_MAP
} MapToType;

extern void UART_EZ_Init(USART_TypeDef* UARTx,u32 baud_rate,
		                               u8 data_len,
		                               char Parity_char,
		                               u8 stop_bits);

extern void UART_Init(USART_TypeDef* UARTx, USART_InitTypeDef* USART_InitStructure);

extern USART_InitTypeDef UART_GetInitStructure(u32 baud_rate,
		                                       u8 data_len,
		                                       char Parity_char,
		                                       u8 stop_bits);

extern void UART_SendByte(USART_TypeDef* USARTx,u16 dat);

extern void UART_Send(USART_TypeDef* UARTx, u16 *pucBuffer, u16 Len);

extern void UART_SendString(USART_TypeDef* UARTx, char *pucBuffer);

extern void UART_SendStr(USART_TypeDef* USARTx, char *pucBuffer);

extern void UART_SendBytes(USART_TypeDef* USARTx,u8 *dat, u16 Len);


extern void UART_Remap(USART_TypeDef* UARTx, FunctionalState NewState);

extern void UART_EnableRX(USART_TypeDef* UARTx);

extern void UART_DisableRX(USART_TypeDef* UARTx);

//---------------------------------------------------------------------
//
//  UART  DBG_Print  support
//
//---------------------------------------------------------------------

extern USART_TypeDef* DBG_UART;

extern void       dbg_InitUART(USART_TypeDef* UARTx);
extern void       dbg_send(USART_TypeDef* USARTx, char *pucBuffer, u16 Len);
extern signed int dbg_printf(const char *pFormat, ...);
extern void dbg_send_bytes( char *pucBuffer, u16 Len);
extern void dbg_send_words( u16 *pucBuffer, u16 Len);
#endif
